
#ifndef _PartDataItem_H_
#define _PartDataItem_H_

#include "DataxApi.hpp"
#include "../OLCore/AbstractDataItem.hpp"
#include "../OLApp/defines.hpp"
#include "../OLApp/Application.hpp"

#include <QTreeWidgetItem>
#include <QTreeWidget>
#include <QLineEdit>
#include <QFileInfo>

#include <vtkAssembly.h>
#include <vtkFeatureEdges.h>
//#include <vtkDataSetMapper.h>
#include <vtkPolyDataMapper.h>
//#include <vtkUnstructuredGrid.h>
#include <vtkPolyDataNormals.h>
#include <vtkTextProperty.h>
#include <vtkBillboardTextActor3D.h>
#include <vtkTransform.h>


namespace NSCore {
	class AbstractROGeometry;
}

namespace NS3d {
	class ROGeometry;
}

namespace NSDatax {


	enum PartType {
		PartMesh,
		PartFace,
		PartSolid,
		Unkown
	};

	class DATAXAPI PartDataItem :
		public NSCore::AbstractDataItem
	{
	public:

	public:
		PartDataItem(QTreeWidgetItem* view);
		PartDataItem(QTreeWidget* tree);
		PartDataItem();
		~PartDataItem() override;
	public:
		/*get*/
		QString getFileSize();
		QString getFileType();
		QString getFileName();
		QString getTypeAsString();
		QString getFilePath() { return m_filepath; };
		QString getDisplayName() { return m_display; }

		const PartType& getType() { return m_type; };
		inline Sp(vtkActor) getActor() { return m_actor; };
		inline Sp(NS3d::ROGeometry) getROGeometry() { return m_assembly; };
		inline Sp(vtkPolyData) getPartInput() { return m_polydata; };
		inline Sp(vtkBillboardTextActor3D) getDisplayLabel() { return m_meta_label; }
		/*Set*/
		void setFilePath(QString file);
		void setType(const PartType& type) { m_type = type; };
		void setPartInput(Sp(vtkPolyData) polydata);
		void updataMapper(Sp(vtkMapper) mapper);
		void resetMapper();
		void setDisplay(QString _name, double* postion = nullptr);
		/*Color*/
		void resetPartColor();
		void getPartColor(double* color);
		void setPartColor(double r, double g, double b);
		void resetMeshColor();
		void getMeshColor(double* color);
		void setMeshColor(double r, double g, double b);
		void resetLabelColor();
		void getLabelColor(double* color);
		void setLabelColor(double r, double g, double b);
		void resetEdgeColor();
		void getEdgeColor(double* color);
		void setEdgeColor(double r, double g, double b);
		/*LineWidth*/
		void getEdgeLineWidth();
		void setEdgeLineWidth(double linewidth);

	public:
		virtual inline QString className() override { return "PartDataItem"; };
		virtual void getPropertyTree(QTreeWidget* p_tree) override;

	protected:
		void init();

	private:
		PartType m_type{ Unkown };
		QString m_filepath{};
		QString m_display{"object"};

		Sp(vtkPolyData) m_polydata { nullptr };
		Sp(NS3d::ROGeometry) m_assembly { nullptr };
		Sp(vtkActor) m_actor { nullptr };
		Sp(vtkActor) m_edge_actor { nullptr };
		Sp(vtkPolyDataMapper) m_polydata_mapper { nullptr };
		Sp(vtkBillboardTextActor3D) m_meta_label { nullptr };
		/*Action*/

		/*PROPERTY - COLOR*/
		double m_part_color[3]{};
		double m_label_color[3]{};
		double m_mesh_color[3]{};
		double m_edge_color[3]{};
		double m_default_part_color[3]{ 0.05, 0.30, 0.60 };
		double m_default_mesh_color[3]{ 0.12, 0.3, 0.15 };
		double m_default_label_color[3]{ 1.0, 0.0, 0.0 };
		double m_default_edge_color[3]{ 0.0, 0.0, 0.0 };
		/*PROPERTY - LINEWIDTH*/
		double m_linewidth{ 2 };

	};

}



#endif

